#include "LOC_scrnframe.h"
#include <avr/pgmspace.h>
/*********************/
/*	Local Dfinitions */
/*********************/








/*******************/
/*	Local Variables*/
/*******************/


/**	Array holding the charachters to be displayed on the screen.
*/
static u8			u8ScrnBuffData[SCR_u8SCREEN_BUFFER_LENGTH];


/**	Variable Pointing to the next charachter to be refreshed on screen.
*		This variable should circulate the viewable area of the screen.
*	This function should be called from the task refreshing the screen. 
*	This function should be called with 200us period.
*/
static u8			u8ViewableAreaCounter;


/*********************************/
/*	Local Functions' Declaration */
/*********************************/




/***********************************/
/*	External Functions' Definition */
/***********************************/


/**	Initializes module local variables.
*		This function will initialize the screen buffer to all zeros 
*	except the last charachter. It will remain empty so that the application 
*	will fill it with the first valid charechter from the message..
*/
void SCR_vidInit(void)
{
	

	u8ViewableAreaCounter	= TYP_u8ZERO;

}





/** This function gets a pointer to the data to be copied to the buffer.
*/
void SCR_vidSetBuffer(u8 u8SCRStart, u8 * pu8Data, u8 u8Length)
{

	u8 u8Iterator;

	for (u8Iterator = u8SCRStart; u8Iterator < SCR_u8SCREEN_BUFFER_LENGTH; u8Iterator++)
	{
	
		u8ScrnBuffData[u8Iterator] = pu8Data[u8Iterator];	

	}


	return;
}


/** This function sets a single byte at a certain index in the screen.
*/
void SCR_vidSetByte(u8 u8Index, u8 u8Data)
{
	if (u8Index < SCR_u8SCREEN_BUFFER_LENGTH)
	{
	
		u8ScrnBuffData[u8Index] = u8Data;
	}
	return;
}

/** Returns the next byte to be sent to screen.
*/
u8 SCR_u8GetReadyByte(void)
{

	u8 u8ReturnValue;


	u8ReturnValue = u8ScrnBuffData[u8ViewableAreaCounter];

	u8ViewableAreaCounter++;

	if (u8ViewableAreaCounter >=  SCR_u8SCREEN_BUFFER_LENGTH)
	{
		u8ViewableAreaCounter = TYP_u8ZERO;
	}
	
	return u8ReturnValue;

}

/********************************/
/*	Local Functions' Definition */
/********************************/
